4ab489
@@ -124,7 +124,7 @@
public class ConnectController {
 		Map<String, List<Connection<?>>> connections = connectionRepository.findAllConnections();
 		model.addAttribute("providerIds", connectionFactoryLocator.registeredProviderIds());		
 		model.addAttribute("connectionMap", connections);
-		return connectView("status");
+		return connectView();
 	}
 
 	/**
@@ -132,14 +132,14 @@
public class ConnectController {
 	 */
 	@RequestMapping(value="/{providerId}", method=RequestMethod.GET)
 	public String connectionStatus(@PathVariable String providerId, NativeWebRequest request, Model model) {
+		setNoCache(request);
 		processFlash(request, model);
 		List<Connection<?>> connections = connectionRepository.findConnections(providerId);
-		setNoCache(request);
 		if (connections.isEmpty()) {
-			return connectView(providerId + "Connect"); 
+			return connectView(providerId); 
 		} else {
 			model.addAttribute("connections", connections);
-			return connectView(providerId + "Connected");			
+			return connectedView(providerId);			
 		}
 	}
 
@@ -201,7 +201,61 @@
public class ConnectController {
 	@RequestMapping(value="/{providerId}/{providerUserId}", method=RequestMethod.DELETE)
 	public RedirectView removeConnection(@PathVariable String providerId, @PathVariable String providerUserId, HttpServletRequest request) {
 		connectionRepository.removeConnection(new ConnectionKey(providerId, providerUserId));
-		return connectionStatusRedirect("../" + providerId);
+		return connectionStatusRedirect(providerId);
+	}
+
+	// subclassing hooks
+	
+	/**
+	 * Returns the ConnectionFactoryLocator.
+	 */
+	protected ConnectionFactoryLocator getConnectionFactoryLocator() {
+		return connectionFactoryLocator;
+	}
+	
+	/**
+	 * Returns the ConnectionRepository.
+	 */
+	protected ConnectionRepository getConnectionRepository() {
+		return connectionRepository;
+	}
+	
+	/**
+	 * Returns a RedirectView with the URL to redirect to after a connection is created or deleted.
+	 * Defaults to "/connect/{providerId}" relative to the servlet context path. 
+	 * May be overridden to handle custom redirection needs.
+	 * @param providerId the ID of the provider for which a connection was created or deleted.
+	 */
+	protected RedirectView connectionStatusRedirect(String providerId) {
+		return new RedirectView("/connect/" + providerId, true);
+	}
+
+	/**
+	 * Returns the view name of a general connection status page, typically displaying the user's connection status for all providers.
+	 * Defaults to "/connect/status". May be overridden to return a custom view name.
+	 */
+	protected String connectView() {
+		return getViewPath() + "status";
+	}
+
+	/**
+	 * Returns the view name of a page to display for a provider when the user is not connected to the provider.
+	 * Typically this page would offer the user an opportunity to create a connection with the provider.
+	 * Defaults to "connect/{providerId}Connect". May be overridden to return a custom view name.
+	 * @param providerId the ID of the provider to display the connection status for.
+	 */
+	protected String connectView(String providerId) {
+		return getViewPath() + providerId + "Connect";		
+	}
+
+	/**
+	 * Returns the view name of a page to display for a provider when the user is connected to the provider.
+	 * Typically this page would allow the user to disconnect from the provider.
+	 * Defaults to "connect/{providerId}Connected". May be overridden to return a custom view name.
+	 * @param providerId the ID of the provider to display the connection status for.
+	 */
+	protected String connectedView(String providerId) {
+		return getViewPath() + providerId + "Connected";		
 	}
 
 	// internal helpers
@@ -210,10 +264,6 @@
public class ConnectController {
 		return "connect/";
 	}
 	
-	private String connectView(String name) {
-		return getViewPath() + name;		
-	}
-
 	private void addConnection(Connection<?> connection, ConnectionFactory<?> connectionFactory, WebRequest request) {
 		try {
 			connectionRepository.addConnection(connection);
@@ -254,10 +304,6 @@
public class ConnectController {
 		}
 	}
 
-	private RedirectView connectionStatusRedirect(String relativePath) {
-		return new RedirectView(relativePath, true);
-	}
-	
 	private void setNoCache(NativeWebRequest request) {
 		HttpServletResponse response = request.getNativeResponse(HttpServletResponse.class);
 		if (response != null) {
